# Maintainer: kpcyrd <git@rxv.cc>
# Contributor: kpcyrd <git@rxv.cc>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@alpinelinux.org>
pkgname=cjdns
pkgver=20.7
pkgrel=0
pkgdesc="A routing engine designed for security, scalability, speed and ease of use"
url="https://github.com/cjdelisle/cjdns"
arch="all !mips64"
license="GPL-3.0-or-later"
makedepends="nodejs python3 linux-headers libseccomp-dev"
install="$pkgname.post-install"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/cjdelisle/cjdns/archive/cjdns-v$pkgver.tar.gz
	no-march-flag.patch
	0001-seccomp-handle-__NR_clock_gettime64-when-appropriate.patch"

builddir="$srcdir/$pkgname-$pkgname-v$pkgver"

build() {
	export CJDNS_RELEASE_VERSION="$pkgver"
	node ./node_build/make.js
}

check() {
	./cjdroute --help >/dev/null
}

package() {
	install -Dm755 cjdroute "$pkgdir/usr/sbin/cjdroute"
	install -Dm755 contrib/openrc/cjdns "$pkgdir/etc/init.d/cjdns"
	install -Dm644 doc/man/cjdroute.conf.5 \
		"$pkgdir/usr/share/man/man5/cjdroute.conf.5"
	install -Dm 644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
	install -Dm644 -t "$pkgdir/usr/share/doc/$pkgname" \
		doc/admin-api.md \
		doc/configure.md \
		doc/djc_layer_model.md \
		doc/nat-gateway.md \
		doc/network-services.md \
		doc/non-root-user.md \
		doc/security_specification.md \
		doc/shorewall_and_vpn_gateway_howto.md \
		doc/tunnel.md
}

sha512sums="db103e70e3d9f5e4958dcbeed51df358450f9489b6573f9b9eddc1839ee2051fe5180eede894b465e92915fabcb4cb64ce08a41c06450f14de75943879633f25  cjdns-20.7.tar.gz
0c487a46609b75408d83cee954fc49f47997f0e9ee2bb8f64c3edc7e67273e5e90b4b2028847e09faa4bd1310b82f1a86fa7d0d0c42f18510cc9dcd4bccb8808  no-march-flag.patch
33f78eed9ee8d417c8f055a1dc5e0c38ebaee2e7a87a6218ac9e58cefb9a5498821c10a68c2ced4fe4a3c19df22bdae97217db5da70ec253adb343a0b9111802  0001-seccomp-handle-__NR_clock_gettime64-when-appropriate.patch"
